# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=hypercorn
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.17.3
pkgrel=3
pkgdesc='An ASGI Server based on Hyper libraries and inspired by Gunicorn (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://hypercorn.readthedocs.io/'
msys2_repository_url='https://github.com/pgjones/hypercorn'
msys2_references=(
  'purl: pkg:pypi/hypercorn'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-h11"
         "${MINGW_PACKAGE_PREFIX}-python-h2"
         "${MINGW_PACKAGE_PREFIX}-python-priority"
         "${MINGW_PACKAGE_PREFIX}-python-toml"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions"
         "${MINGW_PACKAGE_PREFIX}-python-wsproto")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-poetry-core")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('1b37802ee3ac52d2d85270700d565787ab16cf19e1462ccfa9f089ca17574165')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
